Skip to content

Add CLI helpers for managing schedules#97

Merged
konstantinoscs merged 6 commits intodevelopfrom
feature/tow-512-add-new-schedule-editor-to-tower-cli
Sep 17, 2025
Merged

Add CLI helpers for managing schedules#97
konstantinoscs merged 6 commits intodevelopfrom
feature/tow-512-add-new-schedule-editor-to-tower-cli

Conversation

@bradhe
Copy link
Contributor

@bradhe bradhe commented Sep 16, 2025

This PR introduces CLI helpers for managing schedules.

╭─bradhe@Mac ~/Development/tower/tower-cli ‹feature/tow-512-add-new-schedule-editor-to-tower-cli●› 
╰─$ cargo run -- schedules create --app=my-test-app --environment=default --cron="*/15 * * * *"
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s
     Running `target/debug/tower schedules create --app=my-test-app --environment=default '--cron=*/15 * * * *'`
✔ Creating schedule Done!
Success! Schedule created with ID: 40bb2360-bb6e-4c90-9780-dc48a498d75c
╭─bradhe@Mac ~/Development/tower/tower-cli ‹feature/tow-512-add-new-schedule-editor-to-tower-cli●› 
╰─$ cargo run -- schedules list                                                                
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s
     Running `target/debug/tower schedules list`
 ID                                    App          Environment  Cron         
------------------------------------------------------------------------------
 40bb2360-bb6e-4c90-9780-dc48a498d75c  my-test-app  default      */15 * * * * 
 ╭─bradhe@Mac ~/Development/tower/tower-cli ‹feature/tow-512-add-new-schedule-editor-to-tower-cli●› 
╰─$ cargo run -- schedules delete 40bb2360-bb6e-4c90-9780-dc48a498d75c
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.09s
     Running `target/debug/tower schedules delete 40bb2360-bb6e-4c90-9780-dc48a498d75c`
✔ Deleting schedule Done!
Success! Schedule 40bb2360-bb6e-4c90-9780-dc48a498d75c deleted

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds comprehensive CLI functionality for managing schedules in Tower applications. The implementation provides CRUD operations for schedules with support for cron expressions and runtime parameters.

Key changes include:

  • New CLI module with commands for creating, listing, updating, and deleting schedules
  • API integration functions for all schedule operations with proper error handling
  • Command-line argument parsing for schedule parameters and filters

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/tower-cmd/src/schedules.rs Implements CLI commands and handlers for schedule management operations
crates/tower-cmd/src/lib.rs Integrates the schedules module into the main CLI application
crates/tower-cmd/src/api.rs Adds API client functions for schedule operations with response handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +180 to +182
if cron.is_none() {
output::die("You must specify a cron string (--cron) for this schedule");
}
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update command requires a cron parameter but doesn't allow updating other fields independently. Consider making cron optional in updates to allow partial updates of schedule properties.

Suggested change
if cron.is_none() {
output::die("You must specify a cron string (--cron) for this schedule");
}
// Allow partial updates: cron is optional.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose you might wanna update the parameters instead of the cron.

match serde_json::from_str::<HashMap<String, String>>(params_str) {
Ok(params) => Some(params),
Err(_) => {
output::die("Invalid parameters JSON format. Expected object with string key-value pairs.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we may want to change that in the future... It is common in CLJ world to have env variable config be able to autodetect numbers and keywords etc and coerce them, surely something similar must exist in the Python world? In which case I'd be annoyed I had to specify them as strings in the JSON (even though behind the scenes we'd just coerce them into strings before passing them in as env variables anyhow).

}
}

pub async fn do_update(config: Config, args: &ArgMatches) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I really like this naming pattern of having the outer, side effectful user interaction be do_something that then calls the pure some_the_thing inside. This makes it easier to adapt for the MCP server, where I discovered that e.g. getting exposed to a spinner is a very unfortunate thing to go to an LLM.

.short('e')
.long("environment")
.value_parser(value_parser!(String))
.required(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it should be required as an argument here. I guess we're already doing this elsewhere so it makes sense to continue in this PR, but I would expect to have it go to the default environment, or to be able to set it in other ways than the CLI arg (env var, config file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, good point--we use "default" everywhere else. I'll update this.

@konstantinoscs konstantinoscs merged commit d3ed67e into develop Sep 17, 2025
4 checks passed
@konstantinoscs konstantinoscs deleted the feature/tow-512-add-new-schedule-editor-to-tower-cli branch September 17, 2025 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants